<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>


<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>
        添加房产信息
    </title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/main.css" media="all">

</head>
<body>
<div class="x-body">
    <form class="layui-form layui-form-pane" action="${pageContext.request.contextPath}/homes/edit" id="add">
        <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
            <div class="layui-tab-content" >
                <div class="layui-tab-item layui-show">
                    <input hidden name="id" value="${homes.id}">
                    <div class="layui-form-item">
                        <label class="layui-form-label">
                            <span class='x-red'>*</span>栋数
                        </label>
                        <div class="layui-input-block">
                            <select name="bid" id="building_id">
                                <c:forEach items="${buildingsList}" var="b">
                                    <option <c:if test="${b.id==homes.bid}">selected</c:if> value="${b.id}">${b.remark}</option>
                                </c:forEach>
                            </select>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">
                            <span class='x-red'>*</span>房产名称
                        </label>
                        <div class="layui-input-block">
                            <input type="text" name="hname" autocomplete="off" placeholder="控制在80个汉字，160个字符以内"
                                   class="layui-input" value="${home1.name}">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">
                            <span class='x-red'>*</span>户主名称
                        </label>
                        <div class="layui-input-block">
                            <select name="pid" >
                                <c:forEach items="${personnels}" var="p">
                                    <option <c:if test="${homes.pid==p.id}">selected</c:if> value="${p.id}">${p.name}</option>
                                </c:forEach>
                            </select>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">
                            <span class='x-red'>*</span>房间数
                        </label>
                        <div class="layui-input-block">
                            <input type="text" name="number" autocomplete="off" placeholder=""
                                   class="layui-input" lay-verify="required|number" value="${homes.number}">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">
                            <span class='x-red'>*</span>单元
                        </label>
                        <div class="layui-input-block">
                            <input type="text" name="unit" autocomplete="off" placeholder="请输入数字"
                                   class="layui-input" lay-verify="required|number" value="${homes.unit}">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">
                            <span class='x-red'>*</span>楼层
                        </label>
                        <div class="layui-input-block">
                            <input type="text" name="floor" autocomplete="off" placeholder="请输入数字"
                                   class="layui-input" lay-verify="required|number" value="${homes.floor}">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">
                            <span class='x-red'>*</span>入住时间
                        </label>

                        <div class="layui-input-inline">
                            <input class="layui-input" name="housingTime" placeholder="入住时间" id="LAY_demorange_s" value="<fmt:formatDate pattern="yyyy-MM-dd" value="${homes.housingTime}"/>">
                        </div>

                    </div>
                    <div class="layui-form-item layui-form-text">
                        <label class="layui-form-label">
                            <span class='x-red'>*</span>描述
                        </label>
                        <div class="layui-input-block">
                            <textarea placeholder="请输入内容" name="remark" class="layui-textarea">${homes.remark}</textarea>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <button class="layui-btn" type="submit" lay-filter="add" lay-submit="">
                            保存
                        </button>
                    </div>
                    <!--</form>-->
                    <div style="height:100px;"></div>
                </div>

            </div>

        </div>
    </form>
</div>
<script src="${pageContext.request.contextPath}/lib/layui/layui.js" charset="utf-8"></script>
<script src="${pageContext.request.contextPath}/js/x-layui.js" charset="utf-8"></script>
<script src="${pageContext.request.contextPath}/js/jquery.min.js" charset="utf-8"></script>
<!--<script src="/static/xiyuan/js/jquery.js" charset="utf-8"></script>-->
<script>

    layui.use(['laydate','element','layer','form'], function(){
        $ = layui.jquery;//jquery

        laydate = layui.laydate;//日期插件
        lement = layui.element();//面包导航
        layer = layui.layer;//弹出层

        form = layui.form();
        form.render();
        var start = {
            min: '0000-00-00 00:00:00'
            ,max: '2099-06-16 23:59:59'
            ,istoday: false
            ,choose: function(datas){
                //end.min = datas; //开始日选好后，重置结束日的最小日期
                //end.start = datas //将结束日的初始值设定为开始日
            }
        };

        document.getElementById('LAY_demorange_s').onclick = function(){
            start.elem = this;
            laydate(start);
        };

        form.on('select(aihao)', function(data){
            communidy();
        });
        $(function () {
            communidy();
        });
        //communidy();
        function communidy() {
            var communidy = $("#community_id").val();

            $.ajax({
                url:"/xiyuan/home/building.html",
                type:"post",
                dataType:"json",
                data:{communidy:communidy},
                success:function (data) {

                    var dlen =data.length;
                    var str='';
                    for (var i=0;i<dlen;i++){
                        var dt=data[i];
                        str +='<option value="' + dt.id + '">';
                        str +=dt.buildings_name;
                        str +='</option>';
                    }

                    $("#building_id").html(str);
                    form.render('select', 'aihao');
                    //form.render('#building_id');

                }
            })
        }


    })
</script>

</body>
</html>